using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace NoteManger
{
	public class FrmNotPassedNote : Form
	{
		private IContainer components = null;
		private ListView listViewNote;
		private Button btnClose;
		private ImageList imageList;
		private CheckBox ckboxRgnoreDate;
		private ComboBox cbbMonth;
		private Label label3;
		private ComboBox cbbYear;
		private Label label2;
		private TLoginInfo _LoginInfo = new TLoginInfo();
		private NoteRemote _NoteRemoteObject = null;
		public TLoginInfo LoginInfo
		{
			set
			{
				this._LoginInfo = value;
			}
		}
		public NoteRemote NoteRemoteObject
		{
			set
			{
				this._NoteRemoteObject = value;
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(FrmNotPassedNote));
			this.listViewNote = new ListView();
			this.imageList = new ImageList(this.components);
			this.btnClose = new Button();
			this.ckboxRgnoreDate = new CheckBox();
			this.cbbMonth = new ComboBox();
			this.label3 = new Label();
			this.cbbYear = new ComboBox();
			this.label2 = new Label();
			base.SuspendLayout();
			this.listViewNote.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.listViewNote.FullRowSelect = true;
			this.listViewNote.Location = new System.Drawing.Point(3, 3);
			this.listViewNote.Name = "listViewNote";
			this.listViewNote.Size = new System.Drawing.Size(577, 313);
			this.listViewNote.SmallImageList = this.imageList;
			this.listViewNote.TabIndex = 7;
			this.listViewNote.TabStop = false;
			this.listViewNote.UseCompatibleStateImageBehavior = false;
			this.listViewNote.View = View.Details;
			this.listViewNote.DoubleClick += new EventHandler(this.listViewNote_DoubleClick);
			this.imageList.ImageStream = (ImageListStreamer)componentResourceManager.GetObject("imageList.ImageStream");
			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
			this.imageList.Images.SetKeyName(0, "summary.ico");
			this.imageList.Images.SetKeyName(1, "Card.ico");
			this.imageList.Images.SetKeyName(2, "Card-Add.ico");
			this.imageList.Images.SetKeyName(3, "Card-Delete.ico");
			this.imageList.Images.SetKeyName(4, "Mail-Forward.ico");
			this.imageList.Images.SetKeyName(5, "Connect.ico");
			this.imageList.Images.SetKeyName(6, "Certificate.ico");
			this.imageList.Images.SetKeyName(7, "Loginout.ico");
			this.imageList.Images.SetKeyName(8, "key.ico");
			this.imageList.Images.SetKeyName(9, "User-Add.ico");
			this.imageList.Images.SetKeyName(10, "configure.ico");
			this.imageList.Images.SetKeyName(11, "refresh.ico");
			this.imageList.Images.SetKeyName(12, "Card-New.ico");
			this.imageList.Images.SetKeyName(13, "Card-Edit.ico");
			this.imageList.Images.SetKeyName(14, "convert.ico");
			this.imageList.Images.SetKeyName(15, "search.ico");
			this.imageList.Images.SetKeyName(16, "Export.ico");
			this.imageList.Images.SetKeyName(17, "Flow Chart.ico");
			this.imageList.Images.SetKeyName(18, "User-Edit.ico");
			this.imageList.Images.SetKeyName(19, "User-Security-2.ico");
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.Location = new System.Drawing.Point(505, 320);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(75, 23);
			this.btnClose.TabIndex = 8;
			this.btnClose.TabStop = false;
			this.btnClose.Text = "关闭(&C)";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.ckboxRgnoreDate.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.ckboxRgnoreDate.AutoSize = true;
			this.ckboxRgnoreDate.Cursor = Cursors.Hand;
			this.ckboxRgnoreDate.Location = new System.Drawing.Point(173, 325);
			this.ckboxRgnoreDate.Name = "ckboxRgnoreDate";
			this.ckboxRgnoreDate.Size = new System.Drawing.Size(72, 16);
			this.ckboxRgnoreDate.TabIndex = 38;
			this.ckboxRgnoreDate.Text = "忽略月份";
			this.ckboxRgnoreDate.UseVisualStyleBackColor = true;
			this.ckboxRgnoreDate.CheckedChanged += new EventHandler(this.ckboxRgnoreDate_CheckedChanged);
			this.cbbMonth.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.cbbMonth.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbMonth.FormattingEnabled = true;
			this.cbbMonth.Items.AddRange(new object[]
			{
				"01",
				"02",
				"03",
				"04",
				"05",
				"06",
				"07",
				"08",
				"09",
				"10",
				"11",
				"12"
			});
			this.cbbMonth.Location = new System.Drawing.Point(129, 322);
			this.cbbMonth.Name = "cbbMonth";
			this.cbbMonth.Size = new System.Drawing.Size(41, 20);
			this.cbbMonth.TabIndex = 37;
			this.cbbMonth.SelectedIndexChanged += new EventHandler(this.cbbMonth_SelectedIndexChanged);
			this.label3.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(101, 327);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(29, 12);
			this.label3.TabIndex = 36;
			this.label3.Text = "月份";
			this.cbbYear.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.cbbYear.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbYear.FormattingEnabled = true;
			this.cbbYear.Items.AddRange(new object[]
			{
				"2008",
				"2009",
				"2010",
				"2011",
				"2012",
				"2013",
				"2014",
				"2015",
				"2016",
				"2017",
				"2018",
				"2019",
				"2020"
			});
			this.cbbYear.Location = new System.Drawing.Point(34, 322);
			this.cbbYear.Name = "cbbYear";
			this.cbbYear.Size = new System.Drawing.Size(64, 20);
			this.cbbYear.TabIndex = 35;
			this.cbbYear.SelectedIndexChanged += new EventHandler(this.cbbYear_SelectedIndexChanged);
			this.label2.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(6, 326);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(29, 12);
			this.label2.TabIndex = 34;
			this.label2.Text = "年份";
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new System.Drawing.Size(583, 346);
			base.Controls.Add(this.ckboxRgnoreDate);
			base.Controls.Add(this.cbbMonth);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.cbbYear);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.listViewNote);
			base.Name = "FrmNotPassedNote";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "我的被置疑日志";
			base.WindowState = FormWindowState.Maximized;
			base.Load += new EventHandler(this.FrmNotPassedNote_Load);
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public FrmNotPassedNote()
		{
			this.InitializeComponent();
			this.listViewNote.ListViewItemSorter = new ListViewColumnSorter();
			this.listViewNote.ColumnClick += new ColumnClickEventHandler(ListViewHelper.ListView_ColumnClick);
			this.CreateColumn();
			this.cbbYear.Text = DateTime.Now.ToString("yyyy-MM-dd").Substring(0, 4);
			this.cbbMonth.Text = DateTime.Now.ToString("yyyy-MM-dd").Substring(5, 2);
		}
		private void CreateColumn()
		{
			ColumnHeader columnHeader = new ColumnHeader();
			columnHeader.Text = "编号";
			columnHeader.Width = 75;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "日期";
			columnHeader.Width = 100;
			columnHeader.TextAlign = HorizontalAlignment.Left;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "主题";
			columnHeader.Width = 200;
			columnHeader.TextAlign = HorizontalAlignment.Left;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "工作量";
			columnHeader.Width = 60;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "正文";
			columnHeader.Width = 200;
			columnHeader.TextAlign = HorizontalAlignment.Left;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "状态";
			columnHeader.Width = 60;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "创建日期";
			columnHeader.Width = 0;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "创建时间";
			columnHeader.Width = 0;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "置疑说明";
			columnHeader.Width = 150;
			columnHeader.TextAlign = HorizontalAlignment.Left;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "审核人";
			columnHeader.Width = 90;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "审核日期";
			columnHeader.Width = 75;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "审核时间";
			columnHeader.Width = 75;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "核定饱和系数";
			columnHeader.Width = 90;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			this.listViewNote.Columns.Add(columnHeader);
		}
		private void GetNoteInfoFromRemoteServer()
		{
			if (this._NoteRemoteObject != null)
			{
				try
				{
					if (!this._NoteRemoteObject.ConnectionTest())
					{
						MessageBox.Show("远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
						return;
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message + "远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					return;
				}
				string[,] array = new string[0, 0];
				string text = "";
				bool flag = false;
				try
				{
					string aNoteYearMonth;
					if (!this.ckboxRgnoreDate.Checked)
					{
						aNoteYearMonth = this.cbbYear.Text + "-" + this.cbbMonth.Text;
					}
					else
					{
						aNoteYearMonth = this.cbbYear.Text;
					}
					flag = this._NoteRemoteObject.GetDetailNoteList(this._LoginInfo.LoginID, "2", aNoteYearMonth, ref array, ref text);
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				if (flag)
				{
					int num = array.GetUpperBound(0) - array.GetLowerBound(0) + 1;
					this.listViewNote.BeginUpdate();
					this.listViewNote.Items.Clear();
					this.listViewNote.Groups.Clear();
					for (int i = 0; i < num; i++)
					{
						if (array[i, 0] == "0")
						{
							ListViewGroup group = new ListViewGroup(string.Concat(new string[]
							{
								"日期 = ",
								array[i, 4],
								"  合计工作量 = ",
								array[i, 5],
								"  核定工作量 = ",
								array[i, 13]
							}));
							this.listViewNote.Groups.Add(group);
						}
						else
						{
							ListViewItem listViewItem = new ListViewItem();
							int index = this.listViewNote.Groups.Count - 1;
							listViewItem.Group = this.listViewNote.Groups[index];
							listViewItem.Text = array[i, 0];
							listViewItem.SubItems.Add(array[i, 4]);
							listViewItem.SubItems.Add(array[i, 2]);
							listViewItem.SubItems.Add(array[i, 5]);
							listViewItem.SubItems.Add(array[i, 3]);
							if (array[i, 6] == "0")
							{
								listViewItem.SubItems.Add("未审核");
								listViewItem.ImageIndex = 1;
							}
							if (array[i, 6] == "1")
							{
								listViewItem.SubItems.Add("已审核");
								listViewItem.ForeColor = System.Drawing.Color.Blue;
								listViewItem.ImageIndex = 2;
							}
							if (array[i, 6] == "2")
							{
								listViewItem.SubItems.Add("置疑");
								listViewItem.ForeColor = System.Drawing.Color.Red;
								listViewItem.ImageIndex = 3;
							}
							listViewItem.SubItems.Add(array[i, 7]);
							listViewItem.SubItems.Add(array[i, 8]);
							listViewItem.SubItems.Add(array[i, 9]);
							listViewItem.SubItems.Add(array[i, 10]);
							listViewItem.SubItems.Add(array[i, 11]);
							listViewItem.SubItems.Add(array[i, 12]);
							listViewItem.SubItems.Add(array[i, 13]);
							this.listViewNote.Items.Add(listViewItem);
						}
					}
					this.listViewNote.EndUpdate();
					this.listViewNote.Refresh();
					if (this.listViewNote.Items.Count == 0)
					{
						ListViewGroup group = new ListViewGroup("未发现有被置疑数据，请更换条件试试看！");
						this.listViewNote.Groups.Add(group);
						ListViewItem listViewItem = new ListViewItem();
						int index = this.listViewNote.Groups.Count - 1;
						listViewItem.Group = this.listViewNote.Groups[index];
						listViewItem.Text = "";
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						listViewItem.SubItems.Add("");
						this.listViewNote.Items.Add(listViewItem);
					}
				}
				else
				{
					MessageBox.Show(text, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
			}
		}
		private static Array ChangeArrayLength(Array oriArray, int Count)
		{
			Type elementType = oriArray.GetType().GetElementType();
			Array array = Array.CreateInstance(elementType, Count);
			Array.Copy(oriArray, 0, array, 0, Math.Min(oriArray.Length, Count));
			return array;
		}
		private void FrmNotPassedNote_Load(object sender, EventArgs e)
		{
			this.GetNoteInfoFromRemoteServer();
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void listViewNote_DoubleClick(object sender, EventArgs e)
		{
			if (this.listViewNote.SelectedItems.Count == 1)
			{
				try
				{
					if (!this._NoteRemoteObject.ConnectionTest())
					{
						MessageBox.Show("远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
						return;
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message + "远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					return;
				}
				if (!(this.listViewNote.SelectedItems[0].Text.Trim() == ""))
				{
					FrmNoteInfo frmNoteInfo = new FrmNoteInfo();
					frmNoteInfo.NoteID = this.listViewNote.SelectedItems[0].Text;
					frmNoteInfo.LoginInfo = this._LoginInfo;
					frmNoteInfo.NoteRemoteObject = this._NoteRemoteObject;
					frmNoteInfo.ShowDialog();
					frmNoteInfo.Dispose();
				}
			}
		}
		private void cbbYear_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.GetNoteInfoFromRemoteServer();
		}
		private void cbbMonth_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.GetNoteInfoFromRemoteServer();
		}
		private void ckboxRgnoreDate_CheckedChanged(object sender, EventArgs e)
		{
			this.GetNoteInfoFromRemoteServer();
		}
	}
}
